<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!--360浏览器优先以webkit内核解析-->

    <title>H+ 后台主题UI框架 - 主页示例</title>

    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="static/js/plugins/layui/css/layui.css">
    <link href="static/css/bootstrap.min.css?v=3.3.7" rel="stylesheet"/>
    <link href="static/css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="static/css/animate.css" rel="stylesheet"/>
    <link href="static/css/style.css?v=4.1.0" rel="stylesheet"/>
    <style>
        .mt-60 {
            margin-top: -60px;
        }
        .layui-table img {
            max-width: 300px
        }
        .layui-form-label{
            width: 150px;
        }
        .layui-table-cell {
            text-align: center;
        }
        .layui-input-block input{
            width: 350px;
        }
        .layui-textarea{
            height: 30px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="demoTable">
                    搜索：
                    <div class="layui-inline">
                        <input class="layui-input" name="id" id="demoReload" autocomplete="off">
                    </div>
                    <button class="layui-btn" data-type="reload" id="ss">查询</button>
                    <%--						    <button class="layui-btn" data-type="reload" id="ss2">仅查询id</button>--%>
                    <%--					        <button class="layui-btn" data-type="reload" id="ss3">仅查询用户名</button>--%>
                    <%--							<button class="layui-btn" data-type="reload" id="ss4">仅查询手机号</button>--%>
                    <%--						    <button class="layui-btn" data-type="reload" id="ss5">仅查询性别</button>--%>
                    <%--						    <button class="layui-btn" data-type="reload" id="ss6">仅查询邮箱</button>--%>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight mt-60">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <table class="layui-hide" id="test" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="static/module/treetable-lay/treetable.js" charset="utf-8"></script>
<script src="static/module/treetable-lay/treetable.css" charset="utf-8"></script>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delAll"> 批量删除</button>
    </div>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    window.name = "upd";
    layui.use(['form', 'upload', 'table', 'element', 'layer', 'laydate'], function () {
        let $ = layui.jquery
        let upload = layui.upload
        let element = layui.element
        let layer = layui.layer;
        let laydate = layui.laydate;
        let table = layui.table;
        var form = layui.form
        laydate.render({
            elem: '#grounding_date'
            //设置开始日期、日期日期的 input 选择器
            //数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
            , range: ['#grounding_date_from', '#grounding_date_to']
        });
//初始化时查询
        var hx = table.render({
            elem: '#test',
            height: 480,
            url: 'gly?opr=dlr',
            page: true,
            skin: 'line',
            toolbar: '#toolbarDemo',
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'id', title: '编号', sort: true,hide:true},
                {field: 'bt', title: '标题', sort: true,width: "8%"},
                {field: 'nr', title: '内容', sort: true,width: "30%"},
                {field: 'lx', title: '类型',sort: true,width: "8%"},
                {field: 'name', title: '操作人', sort: true,width: "8%"},
                {field: 'datee', title: '操作时间', sort: true},
                {title: '操作',toolbar: '#barDemo'}]]
        })
        table.on('toolbar(test)', function (obj) {
            switch (obj.event) {  // 监听添加操作
                case 'delAll':
                    var checkStatus = table.checkStatus('test'),
                        data = checkStatus.data,
                        userId = "";
                    if (data.length > 0) {
                        for (var i in data) {
                            userId += data[i].id + ",";
                        }
                        console.log(userId);//打印获取到选中的id，用，分割
                        layer.confirm('确定删除选中的用户？', {icon: 3, title: '提示信息'}, function (index) {
                            $.ajax({
                                url: "gly?opr=dlrizhiplsc",
                                type: "POST",
                                data: {id: userId},
                                success: function (msg) {
                                    if (msg == "true") {
                                        layer.msg('删除成功!', {icon: 1, time: 1000});
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="登录操作";
                                        let gn="登录日志批量删除";
                                        let jg="成功";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                        hx.reload({
                                            page: {
                                                curr: 1
                                            }
                                        });
                                    } else {
                                        layer.msg('删除失败', {time: 1000});
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="登录操作";
                                        let gn="登录日志批量删除";
                                        let jg="失败";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                    }
                                }
                            });
                        });
                    } else {
                        layer.msg('请选择删除的数据!', {icon: 1, time: 1000});  //如果未选择数据，则提示。
                    }
                    break;
            }
        });
        //条件查询
        $("#ss").click(function () {
            var p_name = $(".layui-input").val()
            if (p_name == null || p_name == "") {
                hx.reload({
                    url: 'gly?opr=lycx',
                    page: {
                        curr: 1
                    }
                });
            } else {
                if (p_name == "已回复" || p_name == "回复留言") {
                    hx.reload({
                        url: 'gly?opr=xxl',
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                } else {
                    hx.reload({
                        url: 'gly?opr=ztcxly',
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                }
            }
        })
        table.on('tool(test)', function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case'del':
                    layer.confirm('真的删除吗', function (index) {
                        $.ajax({
                            "url": "gly?opr=dlrizhiplsc",
                            "dataType": 'text',
                            "type": 'post',
                            "data": {id: obj.data.id},
                            async: false,
                            "success": function (date) {
                                if (date == "true") {
                                    layer.msg('删除成功', {icon: 1, time: 1500}, function () {
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="登录操作";
                                        let gn="登录日志删除";
                                        let jg="成功";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                        hx.reload({
                                            where: {},
                                            page: {
                                                curr: 1
                                            }
                                        });
                                    });
                                } else {
                                    layer.msg('删除失败', {icon: 2, time: 1500});
                                    let b=sessionStorage.obs;
                                    let a=b.replace(/\"/g, "");
                                    let cz="登录操作";
                                    let gn="登录日志删除";
                                    let jg="失败";
                                    $.ajax({
                                        "url": "gly?opr=xmr",
                                        "data": {name:a,cz:cz,gn:gn,jg:jg}
                                    })
                                }
                            }
                        });
                        layer.close(index);
                    });
                    break;
                case 'edit':
                    layer.open({
                        title: '详情',
                        type: 1,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['60%', '60%'],
                        content: $("#editForm"),
                        success: function () {
                            $("#bt").val(obj.data.bt);
                            $("#nr").val(obj.data.nr);
                            $("#lx").val(obj.data.lx);
                            $("#name").val(obj.data.name);
                            $("#datee").val(obj.data.datee);
                        },
                    });
                    break;
            }
        });
    })
</script>
<form id="editForm" method="post" style="display:none;">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">标题:</label>
        <div class="layui-input-block">
                <input class="layui-textarea" type="text" lay-verify="required" id="bt" name="password" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">内容:</label>
        <div class="layui-input-block">
            <input class="layui-textarea" type="text" lay-verify="required" id="nr" name="password" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">请求类型:</label>
        <div class="layui-input-block">
            <input class="layui-textarea" type="text" lay-verify="required" id="lx" name="password" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">操作人:</label>
        <div class="layui-input-block">
            <input class="layui-textarea" type="text" lay-verify="required" id="name" name="password" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">操作时间:</label>
        <div class="layui-input-block">
            <input class="layui-textarea" type="text" lay-verify="required" id="datee" name="password" readonly="readonly">
        </div>
    </div>
</form>
</body>

</html>